﻿using Fonour.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Fonour.Application.Services.Interfaces
{
    public interface IServiceBase<TDto, TEntity>
        where TEntity : Entity
    {
        Task<IEnumerable<TDto>> GetAllListAsync(Expression<Func<TEntity, object>> order);

        /// <summary>
        /// 获取所有数据列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<TDto>> GetAllListAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, object>> order);

        /// <summary>
        /// 根据父级Id获取数据列表
        /// </summary>
        /// <param name="startPage">起始页</param>
        /// <param name="pageSize">页面大小</param>
        /// <returns></returns>
        Task<PageDto<TDto>> GetPageListAsync(int startPage, int pageSize, Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, object>> order);

        /// <summary>
        /// 新增或修改功能
        /// </summary>
        /// <param name="dto">实体</param>
        /// <returns></returns>
        bool InsertOrUpdate(TDto dto);

        /// <summary>
        /// 根据Id集合批量删除
        /// </summary>
        /// <param name="ids">功能Id集合</param>
        void DeleteBatch(List<Guid> ids);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">功能Id</param>
        void Delete(Guid id);

        /// <summary>
        /// 根据Id获取实体
        /// </summary>
        /// <param name="id">功能Id</param>
        /// <returns></returns>
        Task<TDto> GetAsync(Guid id);
    }
}
